<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./../layui/css/layui.css" media="all">
    <script src="./../layui/layui.js"></script>
    <script src="./../js/jquery-1.8.3.min.js"></script>
    <script src="./../js/env.js"></script>
    <title>region</title>
    <style>
        .layui-btn-group {
            margin: 10px 10px;
        }

        .layui-btn {
            margin: 10px 10px;
        }
    </style>
</head>

<body>
    <fieldset class="layui-elem-field layui-field-title">
        <legend>区域管理</legend>
    </fieldset>
    <div class="demoTable">
        <button class="layui-btn " onclick="javascript:window.location.href='./addarea.html'" data-method="offset"
            type="button" style="background-color: #24811a;">添加区域
        </button>
    </div>
    <table id="demo" lay-filter="test"></table>
    <script type="text/html" id="barDemo">

        {{#  if(d.setType != 4 ){ }}
        <i class="layui-icon layui-icon-edit" lay-event="edit" style="font-size: 20px;"></i>&nbsp;&nbsp;&nbsp;
        {{#  } }}
    
        <i class="layui-icon layui-icon-delete layui-btn-xs" lay-event="del"  href="javascript:void(0)"  onclick="onDelete('{{d.id}}')"  style="font-size: 20px;" ></i>
    </script>
</body>

</html>
<script>
if(layui.sessionData('user').userInfo===undefined){
    window.location.href = "../html/login.html"
}
    layui.use(['table'], function () {
        var table = layui.table

        //第一个实例
        table.render({
            elem: '#demo'
            , height: 312
            , url: abc() + '/admin/config/getAreaLatLog' //数据接口
            , page: true //开启分页
            , cols: [[ //表头
                { field: 'id', title: 'id', sort: true, fixed: 'left', align: 'center' }
                , { field: 'areaName', title: '', align: 'center' }
                , { field: 'areaParentId', title: '', align: 'center' }
                , { field: 'longitude', title: '', align: 'center' }
                , { field: 'dimensionality', title: '', align: 'center' }
                , { field: 'lists', title: '', align: 'center' }
                , { field: 'right', title: '操作', toolbar: '#barDemo', align: 'center' }
            ]]
            , request: {
                pageName: 'page' //页码的参数名称，默认：page
                , limitName: 'pageSize' //每页数据量的参数名，默认：limit
            }
            , parseData: function (res) { //res 即为原始返回的数据
                if (res.code !== 0) {
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg //解析提示文本
                    };
                } else {
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.total, //解析数据长度
                        "data": res.data.list //解析数据列表
                    };
                }

            }
        });

    });


</script>